package io.adrainty.bolee.security.web;

import cn.dev33.satoken.oauth2.processor.SaOAuth2ServerProcessor;
import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>OAuthController</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description OAuthController
 * @since 2025/8/1 10:49:18
 */

@RestController
@RequestMapping("/oauth")
@Tag(name = "OAuthController", description = "权限认证接口")
public class OAuthController {

    @Operation(summary = "获取令牌")
    @PostMapping("/token")
    @SuppressWarnings("unchecked")
    public ResultDTO<Object> accessToken() {
        Map<String, Object> result = (Map<String, Object>) SaOAuth2ServerProcessor.instance.token();
        return ResultDTOUtil.success(result);
    }

    @Operation(summary = "登出")
    @PostMapping("/logout")
    public ResultDTO<Boolean> logout() {
        return ResultDTOUtil.success(null);
    }

}
